package com.cenxi;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.event.EventListener;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@SpringBootApplication
@Slf4j
@EnableTransactionManagement
@MapperScan("com.cenxi.dao.mapper")
public class CenxiRoleApplication {
    @Value("${server.port}")
    private  String port;
    @Value("${server.servlet.context-path}")
    private  String path;
    public static void main(String[] args) {
        SpringApplication.run(CenxiRoleApplication.class, args);
    }

    @Bean
    public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
        return args -> {
            String[] beanNames = ctx.getBeanDefinitionNames();
            log.info("项目启动啦，加载了 {} 个bean!!!", beanNames.length);
        };
    }
    @EventListener()
    public void run(ApplicationStartedEvent event){
        log.info("系统启动成功，接口文档地址:"+"http://localhost:"+port + path+"/swagger-ui.html" );
    }
}
